import 'package:distribution_mall_flutter/base/base_service.dart';
import 'package:distribution_mall_flutter/constant/constant.dart';
import 'package:distribution_mall_flutter/http/modules/user.dart';
import 'package:distribution_mall_flutter/router/router.gr.dart';
import 'package:flutter/material.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'login_invite_code_service.g.dart';

class LoginInviteCodeService extends BaseService {
  LoginInviteCodeService(super.ref);

  Future<void> bindInviteCode(String parentCode) async {
    if(parentCode.isEmpty){
      return;
    }
    (await UserApi.bindInvitationCode(parentCode: parentCode)).yes((value) async {
        appRouter.maybePop(true);
    });
  }
}

@riverpod
LoginInviteCodeService loginInviteCodeService(LoginInviteCodeServiceRef ref) {
  return LoginInviteCodeService(ref);
}
